package com.controller;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.Dao.ProcDao;
import com.google.gson.Gson;
import com.pojo.Sight;


@WebServlet("/procCtrj")
public class ProcController4 extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");	
		response.setCharacterEncoding("utf-8");
		String theme = request.getParameter("theme");
		String contant = request.getParameter("contant");
		String title = request.getParameter("title");
		Integer UId= Integer.valueOf(request.getParameter("uid"));
		ProcDao ProcDao =new ProcDao();
		Integer count = null;
			try {
				count = ProcDao.savetheme(theme);
				ProcDao.savex(UId, title, count, contant);
				System.out.println(theme);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//需要复制的目标文件或目标文件夹
			String pathname = "F:\\apache-tomcat-9.0.5-windows-x86\\apache-tomcat-9.0.5\\wtpwebapps\\HI\\ueditor\\jsp\\upload\\image";
			File file = new File(pathname);
			//复制到的位置
			String topathname = "C:\\Users\\WIN\\Desktop\\Hi\\WebContent\\ueditor\\jsp\\upload";
			File toFile = new File(topathname);
			try {
				ProcDao.copy(file, toFile);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		 
			
		
				
		
		Gson gson = new Gson();
		String jsonStr = gson.toJson(count);
		PrintWriter out = response.getWriter();
		out.print(jsonStr);
	}
}
